#include "stdafx.h"
#include "playerwidget.h"

PlayerWidget::PlayerWidget( QWidget * parent, const QString & playersName )
:   QWidget( parent ),
    m_selected( false ),
    m_score( 0 )
{
    ui.setupUi( this );
    ui.nameLabel->setText( playersName );
    ui.scoreLabel->setText( QString( "%1" ).arg( m_score ) );
    ui.scoreLabel->setStyleSheet( "QWidget { color: red; }" );
}

PlayerWidget::~PlayerWidget()
{
}

void PlayerWidget::setScore( int addToScore )
{
    m_score += addToScore;
    ui.scoreLabel->setText( QString( "%1" ).arg( m_score ) );
}

void PlayerWidget::setAbsolutScore( int score )
{
    m_score = score;
    ui.scoreLabel->setText( QString( "%1" ).arg( m_score ) );
}

void PlayerWidget::setBackroundSelected( bool selected )
{
    m_selected = selected;
    QString styleSheetString;
    if (selected)
        styleSheetString = "QWidget { background: orange; }";

    setStyleSheet( styleSheetString );
}

bool PlayerWidget::isSelected() const
{
    return m_selected;
}

int PlayerWidget::score() const
{
    return m_score;
}
